class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2023-09-13",
      revision: "3cde8c39d65312918eea3a67d23955e0d7476e12"
  version "2023-09-13"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "b355630f50519800bdf0870f1e3ff6121fb8980b61919752e8a84862bb2eb106"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "fec071217002f664c5a00f9aedd62fcee14a15bfcfbd858b2eabae5834828f31"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "ac2317f2f4044fa36a14947fe315a8cec7d4bb57ec814fc3abebe6c81ca87684"
    sha256 cellar: :any_skip_relocation, ventura:        "1c47d8c935cccc6deef0e18d6cefd77ab61abfdc8236137c1f70e6e13fe978e9"
    sha256 cellar: :any_skip_relocation, monterey:       "2ef9eaeb7117f9079568247c4cf7659f4c181de85b15de85590198b5a7c24e51"
    sha256 cellar: :any_skip_relocation, big_sur:        "51d9978e4183dc7f84fbbc8fcf29aaa5e234707dff1b7636ff83072ca47fe4a6"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "a7fdb25223b7e207ffd32c99090c09756cfe5f7c405667b60f21d86518d23b39"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
